package com.gitee.neuray.security.wb.ribs.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gitee.neuray.security.common.msg.ListRestResponse;
import com.gitee.neuray.security.common.msg.ObjectRestResponse;
import com.gitee.neuray.security.common.msg.TableResultResponse;
import com.gitee.neuray.security.common.util.ExcelUtils;
import com.gitee.neuray.security.common.util.Query;
import com.gitee.neuray.security.mail.feign.MailServiceFeignClient;
import com.gitee.neuray.security.mail.vo.SysMailSourceVo;
import com.gitee.neuray.security.wb.ribs.biz.*;
import com.gitee.neuray.security.wb.ribs.feign.StaffFeign;
import com.gitee.neuray.security.wb.ribs.vo.*;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 报销列表查询
 *
 * @author larksys
 * @email ${email}
 * @date 2020-03-19 14:10:38
 */
@RestController
@RequestMapping("ribs")
public class RibsController {
  @Autowired private RibsBiz ribsBiz;
  @Autowired private ClfBiz clfBiz;
  @Autowired private CyfBiz cyfBiz;
  @Autowired private JtfBiz jtfBiz;
  @Autowired private QtfyBiz qtfyBiz;
  @Autowired private WechatBiz wechatBiz;
  @Autowired private ApproveRoleBiz approveRoleBiz;
  @Autowired private StaffFeign staffFeign;

  /**
   * 分页获取列表
   *
   * @param params
   * @return
   */
  @RequestMapping(value = "page", method = RequestMethod.GET)
  public TableResultResponse queryPage(@RequestParam Map<String, Object> params) {
    // 查询列表数据
    Query query = new Query(params);
    return ribsBiz.page(query);
  }

  /**
   * 提交差旅费
   *
   * @return
   */
  @RequestMapping(value = "commitClf", method = RequestMethod.POST)
  public ObjectRestResponse<RibsVo> commitClf(@RequestBody Map map, HttpServletRequest request) {
    System.out.println("STEP-CLF-START-------------------------------------"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    String wxUserId = request.getHeader("wxUserId");
    String orgCode = request.getHeader("orgCode");
    String accessToken = request.getHeader("wxAccessToken");
    String userId = request.getHeader("userId");
    String orgName = null;
    try {
      orgName = URLDecoder.decode(request.getHeader("orgName"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    String name = null;
    try {
      name = URLDecoder.decode(request.getHeader("name"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    String position = null;
    try {
      position = URLDecoder.decode(request.getHeader("position"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }

    Map wechatInfo = new HashMap();
    Map staffInfo = new HashMap();
    wechatInfo.put("wxUserId",wxUserId);
    wechatInfo.put("accessToken",accessToken);

    staffInfo.put("orgCode",orgCode);
    staffInfo.put("orgName",orgName);
    staffInfo.put("position",position);
    staffInfo.put("name",name);

    RibsVo ribsVo = JSONObject.parseObject(JSONObject.toJSONString(map.get("ribsVo")),RibsVo.class);
    /*Map wechatInfo = JSONObject.parseObject(JSONObject.toJSONString(map.get("wechatInfo")),Map.class);
    Map staffInfo = JSONObject.parseObject(JSONObject.toJSONString(map.get("staffInfo")),Map.class);*/
    wechatInfo.put("ids",ribsVo.getIds());

    System.out.println("STEP1-------------------------------------"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

    // 生成报销单号
    String bxdh = "";
    if("ribsVo.getBxdh()".equals(ribsVo.getBxdh())||null == ribsVo.getBxdh()){
      bxdh = createBxdh("CLF");
    }else{
      bxdh = ribsVo.getBxdh();
    }

    ribsVo.setBxzt("2");

    // 检验是否特批
    checkTp(ribsVo);
    System.out.println("STEP2-------------------------------------"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

    // 修改子表差旅费状态为提交,修改报销单号
    for (int i = 0; i < ribsVo.getIds().split(",").length; i++) {
      ClfVo clfVo = new ClfVo();
      clfVo.setBczt(ribsVo.getBxzt()); // 保存状态
      clfVo.setId(ribsVo.getIds().split(",")[i]); // ID
      clfVo.setBxdh(bxdh); // 报销单号
      clfBiz.updClf(clfVo);
    }
    System.out.println("STEP3-------------------------------------"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    // 提交报销单
    ribsVo.setIds(null);
    //ribsVo.setBxdh(bxdh);

    // 特殊：如果乘坐的是火车一等座或者飞机，需要特批。
    // 为避免不必要的数据库交互，先确定报销为非特批
    // 去掉特批
    /*if("0".equals(ribsVo.getTp())){
      List<ClfVo> clfVos = new ArrayList<>();
      ClfVo clfVo = new ClfVo();
      clfVo.setBxdh(bxdh);
      clfVos = clfBiz.selectList(clfVo);

      for(ClfVo clf : clfVos){
        if("2".equals(clf.getGCxfs()) || "3".equals(clf.getGCxfs())
                || "2".equals(clf.getBCxfs()) || "3".equals(clf.getBCxfs())){
          ribsVo.setTp("1");
        }
      }
    }*/
    System.out.println("STEP4-------------------------------------"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

    ribsBiz.commitBXD(ribsVo,bxdh,userId);

    try {
      wechatBiz.excelAndSend(wechatInfo,"外阜差旅费",ribsVo,staffInfo,request);
    } catch (IOException e) {
      e.printStackTrace();
    }

    return new ObjectRestResponse<RibsVo>().rel(true);
  }

  @RequestMapping(value = "test", method = RequestMethod.POST)
  public void test(@RequestBody Map map, HttpServletRequest request) {
    try {
      Map wechatInfo = JSONObject.parseObject(JSONObject.toJSONString(map.get("wechatInfo")),Map.class);
      wechatBiz.excelAndSend(wechatInfo,"外阜差旅费",null,null,request);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  /**
   * 提交餐饮费
   *
   * @return
   */
  @RequestMapping(value = "commitCyf", method = RequestMethod.POST)
  public ObjectRestResponse<RibsVo> commitCyf(@RequestBody Map map,HttpServletRequest request) {

    String wxUserId = request.getHeader("wxUserId");
    String orgCode = request.getHeader("orgCode");
    String accessToken = request.getHeader("wxAccessToken");
    String userId = request.getHeader("userId");
    String orgName = null;
    try {
      orgName = URLDecoder.decode(request.getHeader("orgName"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    String name = null;
    try {
      name = URLDecoder.decode(request.getHeader("name"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    String position = null;
    try {
      position = URLDecoder.decode(request.getHeader("position"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }

    Map wechatInfo = new HashMap();
    Map staffInfo = new HashMap();
    wechatInfo.put("wxUserId",wxUserId);
    wechatInfo.put("accessToken",accessToken);

    staffInfo.put("orgCode",orgCode);
    staffInfo.put("orgName",orgName);
    staffInfo.put("position",position);
    staffInfo.put("name",name);

    RibsVo ribsVo = JSONObject.parseObject(JSONObject.toJSONString(map.get("ribsVo")),RibsVo.class);
    /*Map wechatInfo = JSONObject.parseObject(JSONObject.toJSONString(map.get("wechatInfo")),Map.class);
    Map staffInfo = JSONObject.parseObject(JSONObject.toJSONString(map.get("staffInfo")),Map.class);*/
    wechatInfo.put("ids",ribsVo.getIds());
    // 生成报销单号
    String bxdh = "";
    if("ribsVo.getBxdh()".equals(ribsVo.getBxdh())||null == ribsVo.getBxdh()){
      bxdh = createBxdh("CYF");
    }else{
      bxdh = ribsVo.getBxdh();
    }

    ribsVo.setBxzt("2");

    //检验是否特批
    checkTp(ribsVo);

    // 修改子表差旅费状态为提交,修改报销单号
    for (int i = 0; i < ribsVo.getIds().split(",").length; i++) {
      CyfVo cyfVo = new CyfVo();
      cyfVo.setBczt(ribsVo.getBxzt()); // 保存状态
      cyfVo.setId(ribsVo.getIds().split(",")[i]); // ID
      cyfVo.setBxdh(bxdh); // 报销单号
      cyfBiz.updCyf(cyfVo);
    }
    // 提交报销单
    //ribsVo.setBxdh(bxdh);
    ribsVo.setIds(null);

    ribsBiz.commitBXD(ribsVo,bxdh,userId);

    try {
      wechatBiz.excelAndSend(wechatInfo,"餐饮费",ribsVo,staffInfo,request);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return new ObjectRestResponse<RibsVo>().rel(true);
  }
  /**
   * 提交市内交通费
   *
   * @return
   */
  @RequestMapping(value = "commitJtf", method = RequestMethod.POST)
  public ObjectRestResponse<RibsVo> commitSnjtf(@RequestBody Map map,HttpServletRequest request) {

    String wxUserId = request.getHeader("wxUserId");
    String orgCode = request.getHeader("orgCode");
    String accessToken = request.getHeader("wxAccessToken");
    String userId = request.getHeader("userId");
    String orgName = null;
    try {
      orgName = URLDecoder.decode(request.getHeader("orgName"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    String name = null;
    try {
      name = URLDecoder.decode(request.getHeader("name"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    String position = null;
    try {
      position = URLDecoder.decode(request.getHeader("position"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }

    Map wechatInfo = new HashMap();
    Map staffInfo = new HashMap();
    wechatInfo.put("wxUserId",wxUserId);
    wechatInfo.put("accessToken",accessToken);

    staffInfo.put("orgCode",orgCode);
    staffInfo.put("orgName",orgName);
    staffInfo.put("position",position);
    staffInfo.put("name",name);

    RibsVo ribsVo = JSONObject.parseObject(JSONObject.toJSONString(map.get("ribsVo")),RibsVo.class);
    /*Map wechatInfo = JSONObject.parseObject(JSONObject.toJSONString(map.get("wechatInfo")),Map.class);
    Map staffInfo = JSONObject.parseObject(JSONObject.toJSONString(map.get("staffInfo")),Map.class);*/
    wechatInfo.put("ids",ribsVo.getIds());
    // 生成报销单号
    String bxdh = "";
    if("ribsVo.getBxdh()".equals(ribsVo.getBxdh())||null == ribsVo.getBxdh()){
      bxdh = createBxdh("JTF");
    }else{
      bxdh = ribsVo.getBxdh();
    }

    ribsVo.setBxzt("2");

    //检验是否特批
    checkTp(ribsVo);

    // 修改子表差旅费状态为提交,修改报销单号
    for (int i = 0; i < ribsVo.getIds().split(",").length; i++) {
      JtfVo jtfVo = new JtfVo();
      jtfVo.setBczt(ribsVo.getBxzt()); // 保存状态
      jtfVo.setId(ribsVo.getIds().split(",")[i]); // ID
      jtfVo.setBxdh(bxdh); // 报销单号
      jtfBiz.updJtf(jtfVo);
    }
    // 提交报销单
    //ribsVo.setBxdh(bxdh);
    ribsVo.setIds(null);

    ribsBiz.commitBXD(ribsVo,bxdh,userId);
    try {
      wechatBiz.excelAndSend(wechatInfo,"市内交通费",ribsVo,staffInfo,request);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return new ObjectRestResponse<RibsVo>().rel(true);
  }

  /**
   * 提交市内交通费
   *
   * @return
   */
  @RequestMapping(value = "commitQt", method = RequestMethod.POST)
  public ObjectRestResponse<RibsVo> commitQt(@RequestBody Map map,HttpServletRequest request) {

    String wxUserId = request.getHeader("wxUserId");
    String orgCode = request.getHeader("orgCode");
    String accessToken = request.getHeader("wxAccessToken");
    String userId = request.getHeader("userId");
    String orgName = null;
    try {
      orgName = URLDecoder.decode(request.getHeader("orgName"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    String name = null;
    try {
      name = URLDecoder.decode(request.getHeader("name"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    String position = null;
    try {
      position = URLDecoder.decode(request.getHeader("position"),"utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }

    Map wechatInfo = new HashMap();
    Map staffInfo = new HashMap();
    wechatInfo.put("wxUserId",wxUserId);
    wechatInfo.put("accessToken",accessToken);

    staffInfo.put("orgCode",orgCode);
    staffInfo.put("orgName",orgName);
    staffInfo.put("position",position);
    staffInfo.put("name",name);

    RibsVo ribsVo = JSONObject.parseObject(JSONObject.toJSONString(map.get("ribsVo")),RibsVo.class);
    /*Map wechatInfo = JSONObject.parseObject(JSONObject.toJSONString(map.get("wechatInfo")),Map.class);
    Map staffInfo = JSONObject.parseObject(JSONObject.toJSONString(map.get("staffInfo")),Map.class);*/
    wechatInfo.put("ids",ribsVo.getIds());
    // 生成报销单号
    String bxdh = "";
    if("ribsVo.getBxdh()".equals(ribsVo.getBxdh())||null == ribsVo.getBxdh()){
      bxdh = createBxdh("JTF");
    }else{
      bxdh = ribsVo.getBxdh();
    }

    ribsVo.setBxzt("2");

    //检验是否特批
    checkTp(ribsVo);

    // 修改子表差旅费状态为提交,修改报销单号
    for (int i = 0; i < ribsVo.getIds().split(",").length; i++) {
      QtVo qtVo = new QtVo();
      qtVo.setBczt(ribsVo.getBxzt()); // 保存状态
      qtVo.setId(ribsVo.getIds().split(",")[i]); // ID
      qtVo.setBxdh(bxdh); // 报销单号
      qtfyBiz.updQt(qtVo);
    }
    // 提交报销单
    //ribsVo.setBxdh(bxdh);
    ribsVo.setIds(null);

    ribsBiz.commitBXD(ribsVo,bxdh,userId);
    try {
      wechatBiz.excelAndSend(wechatInfo,"其他费用",ribsVo,staffInfo,request);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return new ObjectRestResponse<RibsVo>().rel(true);
  }

  /**
   *  报销单删除
   *
   * @return
   */
  @RequestMapping(value = "delRibs/{bxdh}/{type}", method = RequestMethod.DELETE)
  public ObjectRestResponse<CyfVo> delRibs(@PathVariable String bxdh,@PathVariable String type) {
    RibsVo ribsVo = new RibsVo();
    ribsVo.setBxdh(bxdh);
    if("evection".equals(type)){
      ClfVo clfVo = new ClfVo();
      clfVo.setBxdh(bxdh);
      clfBiz.delete(clfVo);
    }else if("traffic".equals(type)){
      JtfVo jtfVo = new JtfVo();
      jtfVo.setBxdh(bxdh);
      jtfBiz.delete(jtfVo);
    }else if("meal".equals(type)){
      CyfVo cyfVo = new CyfVo();
      cyfVo.setBxdh(bxdh);
      cyfBiz.delete(cyfVo);
    }else if("others".equals(type)){
      QtVo qtVo = new QtVo();
      qtVo.setBxdh(bxdh);
      qtfyBiz.delete(qtVo);
    }
    HistoryVo historyVo = new HistoryVo();
    historyVo.setBxdh(bxdh);
    ribsBiz.deleteHistory(historyVo);
    ribsBiz.delete(ribsVo);
    return new ObjectRestResponse<CyfVo>().rel(true);
  }

  @RequestMapping(value = "historyQuery", method = RequestMethod.GET)
  public ListRestResponse<List<HistoryVo>> historyQuery(@RequestParam Map map, HttpServletRequest request){
    HistoryVo historyVo = JSONObject.parseObject(JSONObject.toJSONString(map),HistoryVo.class);
    List<HistoryVo> historyVos = ribsBiz.historyQuery(historyVo);
    return new ListRestResponse<List<HistoryVo>>("查询成功",historyVos.size(),historyVos);
  }

  @RequestMapping(value = "export", method = RequestMethod.GET)
  public void export(@RequestParam Map<String, Object> params, HttpServletResponse response, HttpServletRequest request)
          throws Exception {
    Query query = new Query(params);
    /*List data = ribsBiz.nopage(query);*/
    String userId = request.getHeader("userid");
    //params.put("staffId",userId);
    // 查询列表数据
    String type = "approve";
    List<RibsVo> list = approveRoleBiz.exportQuery(query,userId);
    List<RibsPageExcelVo> execlData = JSONObject.parseArray(JSONObject.toJSONString(list),RibsPageExcelVo.class);
    /*List<RibsPageExcelVo> execlData =
            JSONArray.parseArray(JSONObject.toJSONString(data), RibsPageExcelVo.class);*/
    ExcelUtils.export(response, "报销列表查询", execlData, RibsPageExcelVo.class);
  }

  @RequestMapping(value = "exportApprove", method = RequestMethod.GET)
  public void exportApprove(@RequestParam Map<String, Object> params, HttpServletResponse response, HttpServletRequest request)
          throws Exception {
    Query query = new Query(params);
    /*List data = ribsBiz.nopage(query);*/
    String userId = request.getHeader("userid");
    //params.put("staffId",userId);
    // 查询列表数据
    String type = "approve";
    List<RibsVo> list = approveRoleBiz.exportApprove(query,userId);
    List<RibsPageExcelVo> execlData = JSONObject.parseArray(JSONObject.toJSONString(list),RibsPageExcelVo.class);
    /*List<RibsPageExcelVo> execlData =
            JSONArray.parseArray(JSONObject.toJSONString(data), RibsPageExcelVo.class);*/
    ExcelUtils.export(response, "报销列表查询", execlData, RibsPageExcelVo.class);
  }

  /**
   * 查询当前登陆人审批角色
   * @param map
   * @return
   */
  @RequestMapping(value = "findRole", method = RequestMethod.GET)
  public List<ApproveRoleVo> findRole(@RequestParam Map map){

    // String userId = request.getHeader("userId");
    String userId = map.get("userId").toString();
    ApproveRoleVo roleVo = new ApproveRoleVo();
    roleVo.setStaffId(userId);
    List<ApproveRoleVo> roleVos = approveRoleBiz.selectList(roleVo);
    //return new ListRestResponse<List<ApproveRoleVo>>("角色列表",roleVos.size(),roleVos);
    return roleVos;
  }

  /**
   * 分页获取列表
   *
   * @param params
   * @return
   */
  @RequestMapping(value = "queryPage", method = RequestMethod.GET)
  public TableResultResponse queryPagePc(@RequestParam Map<String, Object> params, HttpServletRequest request) {

    String userId = request.getHeader("userid");
    //params.put("staffId",userId);
    // 查询列表数据
    Query query = new Query(params);
    return approveRoleBiz.page(query,userId,"query");

  }
  /**
   * 分页获取列表
   *
   * @param params
   * @return
   */
  @RequestMapping(value = "approveQuery", method = RequestMethod.GET)
  public TableResultResponse approveQuery(@RequestParam Map<String, Object> params, HttpServletRequest request) {

    String userId = request.getHeader("userid");
    //params.put("staffId",userId);
    // 查询列表数据
    Query query = new Query(params);
    String type = "approve";
    if("wechat".equals(params.get("type"))){
      type = "wechat";
    }
    return approveRoleBiz.page(query,userId,type);
  }

  /**
   * 根据条件查询，不分角色
   *
   * @param map
   * @return
   */
  @RequestMapping(value = "approveByDetail", method = RequestMethod.GET)
  public ListRestResponse<List<RibsVo>> approveByDetail(@RequestParam Map map, HttpServletRequest request) {
    RibsVo ribsVo = JSONObject.parseObject(JSONObject.toJSONString(map),RibsVo.class);
    return ribsBiz.approveByDetail(ribsVo);
  }
  @RequestMapping(value = "approve",method = RequestMethod.PUT)
  public ObjectRestResponse<ApproveRoleVo> approve(@RequestBody List<RibsVo> ribsVos,HttpServletRequest request){
    for(RibsVo ribsVo : ribsVos){
      ribsBiz.approveRibs(ribsVo,request);
    }

    return new ObjectRestResponse<ApproveRoleVo>().rel(true);
  }

  @RequestMapping(value = "queryDetail",method = RequestMethod.GET)
  public ObjectRestResponse<Map<String,Object>> queryDetail(@RequestParam Map<String,Object> map){
    RibsVo ribsVo = JSONObject.parseObject(JSONObject.toJSONString(map),RibsVo.class);
    return new ObjectRestResponse<Map<String,Object>>().data(ribsBiz.queryDetail(ribsVo)).rel(true);
  }

  @RequestMapping(value = "staffPage",method = RequestMethod.GET)
  public TableResultResponse staffPage(@RequestParam Map<String,Object> params){
    return staffFeign.getStaffInfo(params);
  }


  /** 生成报销单号 */
  public String createBxdh(String bxlx) {
    String bxdh = ribsBiz.getIndex();

    return "DR" + bxlx + bxdh;
  }

  public void checkTp(RibsVo ribsVo){

    ribsVo.setTp("0");
    String staffId = ribsVo.getStaffId();
    ApproveRoleVo approveRoleVo = new ApproveRoleVo();
    approveRoleVo.setStaffId(staffId);
    List<ApproveRoleVo> list = approveRoleBiz.selectList(approveRoleVo);

    //todo 总经理提交是否需要特殊审核

    //如果总金额大于50000元，走特批状态
    /*if(Double.valueOf(ribsVo.getFyhj())>50000){
      ribsVo.setTp("1");
    }*/

    // //如果是部门审批人提交，走总经理特批 (废除)
    // 如果是部门负责人提交，状态置为已复审
    if(list != null && list.size() != 0){
      if("1".equals(list.get(0).getRoleId())){
        // ribsVo.setTp("2");
        ribsVo.setBxzt("4");
      }
    }
  }
  /*@Autowired
  MailServiceFeignClient client;

  public void testAdd() throws Exception {
    SysMailSourceVo entity = new SysMailSourceVo();
    entity.setTitle("邮件标题");
    entity.setSjr("liwd@neuray.com");
    entity.setCsr("lisi@qq.com");
    entity.setAsr("wangwu@qq.com,zhaokiu@163.com");
    entity.setGnbh("123456");
    entity.setFjrbm("fjrbm");
    entity.setYjnrTe("你好 赵总 我们公司已经讨论了这个方案");
    entity.setCrtUser("userid");
    entity.setCrtName("系统管理员");
    entity.setYjsj(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    client.addMail(entity);
  }*/

  @RequestMapping(value = "allCount",method = RequestMethod.GET)
  public ListRestResponse<List<Integer>> allCount(@RequestParam Map<String,Object> map,HttpServletRequest request){
    String userId = request.getHeader("userid");
    return new ListRestResponse<List<Integer>>("查询成功",3,approveRoleBiz.count(map,userId,map.get("type").toString()));
  }

  @RequestMapping(value = "getXS",method = RequestMethod.GET)
  public ListRestResponse<List<SelectVo>> getXS(@RequestParam Map<String,Object> params){
    List<SelectVo> list = approveRoleBiz.getXS(params.get("deptName").toString());
    return new ListRestResponse<List<SelectVo>>("查询成功",list.size(),list);
  }
}
